﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Configuration;
using System.Data.OleDb;

/// <summary>
/// Summary description for Gradovi
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
// [System.Web.Script.Services.ScriptService]
public class Gradovi : System.Web.Services.WebService {

    public Gradovi () {

        //Uncomment the following line if using designed components 
        //InitializeComponent(); 
    }

    [WebMethod]
    public string getCity(int id) {
        string conString = ConfigurationManager.ConnectionStrings["gradovi"].ConnectionString;
        OleDbConnection conn = new OleDbConnection(conString);
        try
        {
            conn.Open();

            string select = "SELECT ImeGrad FROM Gradovi WHERE IdGrad = ?";
            OleDbCommand cmd = new OleDbCommand(select, conn);
            cmd.Parameters.AddWithValue("?", id);

            OleDbDataReader r = cmd.ExecuteReader();
            r.Read();
            return r[0].ToString();
        }
        catch (Exception err)
        {
            return null;
        }

        
    }
    
}

